{# SPDX-FileCopyrightText: © 2015,2023 Siemens AG

   SPDX-License-Identifier: FSFAP
#}
{%- from "listedlicense.xml.twig" import listedLicenseFull -%}
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:spdx="http://spdx.org/rdf/terms#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xml:base="{{ uri }}">
<spdx:SpdxDocument rdf:about="{{ uri }}#SPDXRef-DOCUMENT">
  <spdx:specVersion>SPDX-2.3</spdx:specVersion>
  <spdx:dataLicense>
    {{ listedLicenseFull(licenseList[dataLicense].licenseObj) -}}
  </spdx:dataLicense>
  <spdx:creationInfo>
    <spdx:CreationInfo>
      <spdx:licenseListVersion>3.22</spdx:licenseListVersion>
      <spdx:creator>Person: {{ userName|e }}</spdx:creator>
      <spdx:creator>Organization: {{ organisation|e }}</spdx:creator>
      <spdx:creator>Tool: {{ toolVersion|e }}</spdx:creator>
      <spdx:created>{{ 'now'|date('Y-m-d\\TH:i:s\\Z', 'UTC') }}{# date('c') for ISO 8601 is not parsed by spdxTool #}</spdx:created>
    </spdx:CreationInfo>
  </spdx:creationInfo>
  <spdx:name>{{ documentName|e }}</spdx:name>
  <rdfs:comment>
    This document was created using license information and a generator from Fossology.
  </rdfs:comment>
  {%- for licenseData in licenseList -%}
  {%- if licenseData.licenseObj.spdxId starts with 'LicenseRef-' or licenseData.licenseObj.shortName starts with 'LicenseRef-' or (EnableOsselotExport and licenseData.licenseObj.shortName != 'No_license_found') -%}
  <spdx:hasExtractedLicensingInfo>
    {%- set licId=licenseData.licenseObj.spdxId -%}
    {% if licenseData.licenseObj.shortName starts with 'LicenseRef-' -%}
      {% set licId=licenseData.licenseObj.shortName -%}
    {%- endif -%}
    {% if EnableOsselotExport and licId starts with 'LicenseRef-fossology-' -%}
      {% set licId = licId | replace({'LicenseRef-fossology-':'LicenseRef-'}) -%}
    {% endif -%}
    {% if EnableOsselotExport and not (licId starts with 'LicenseRef-') -%}
      {% set licId = 'LicenseRef-' ~ licId -%}
    {% endif -%}
    <spdx:ExtractedLicensingInfo rdf:about="#{{ licId|replace({' ': '-'})|url_encode }}">
      <spdx:licenseId>{{ licId|replace({' ': '-'})|e }}</spdx:licenseId>
      <spdx:name>{{ licenseData.licenseObj.fullName|e }}</spdx:name>
      <spdx:extractedText><![CDATA[
{{ licenseData.licenseObj.text|replace({'\f':''})
        |replace({']]>':']]]]><![CDATA[>'}) }}
      ]]></spdx:extractedText>
{% if licenseData.licenseObj.url is not empty %}
  {%~ if '&' in licenseData.licenseObj.url %}
      <rdfs:seeAlso>{{ licenseData.licenseObj.url|url_encode }}</rdfs:seeAlso>
  {%~ else %}
      <rdfs:seeAlso>{{ licenseData.licenseObj.url }}</rdfs:seeAlso>
  {%~ endif %}
{% endif %}
    </spdx:ExtractedLicensingInfo>
  </spdx:hasExtractedLicensingInfo>
{%- endif %}{% endfor ~%}
  {{ packageNodes|replace({'\n':'\n  '}) }}
</spdx:SpdxDocument>
</rdf:RDF>